/**
 * 注册验证
 * register_username 注册用户名
 * register_pwd 	 用户密码
 * register_pwd		 用户二次密码
 * register_num		 验证码
 * register_tip		 用户提示
 * 按钮触发事件
 * register_num_button 验证码发送按钮
 * register_button  注册按钮
 */
var register_username=document.getElementById("register_username")
var register_pwd=document.getElementById("register_pwd")
var register_pwd2=document.getElementById("register_pwd2")
var register_num=document.getElementById("register_num")
var register_tip=document.getElementById("register_tip")
var register_email=document.getElementById("register_email")
var register_button=document.getElementById("register_button")

var flag2=0
register_button.onclick=function(){
    console.log("注册")
    if(register_username.value===""){
        console.log("用户名为空")
        register_tip.innerText="用户名不能为空"
        flag2=0
    }else{
        var regExp=/^\w{1,10}$/;
        var ok=regExp.test(register_username.value);
        if(ok){
            if(register_pwd.value===""){
                register_tip.innerText='密码不能为空'
                flag2=0
            }else if(register_pwd.value.length>6){
                register_tip.innerText='密码长度小于等于6位'
                flag2=0
            }
            else if(register_pwd2.value!=register_pwd.value){
                register_tip.innerText='确认密码不一致'
                flag2=0
            }else if(register_email.value===""){
                register_tip.innerText='邮箱不能为空'
                flag2=0
            }else{
                var regExp=/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
                var ok=regExp.test(register_email.value);
                if(ok){
                    register_tip.innerText=""
                    flag2=1
                }else{
                    register_tip.innerText="邮箱不规范"
                    flag2=0
                }
            }
        }else{
            register_tip.innerText="用户名格式不规范（10个以内字符）"
            flag2=0
        }
    }
    if(flag2===1){
        url="information.html?username="+register_username.value+"&email="+register_email.value;
        location.href=url;
    }
}
